package com.qidian.buy.controller;

import com.qidian.buy.entity.Customer;
import com.qidian.buy.service.ICustomerService;
import com.qidian.buy.util.pojo.LayuiTableDTO;
import com.qidian.buy.util.pojo.QDResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author 郭浩
 */
@RestController
@RequestMapping("/customer")
@CrossOrigin
public class CustomerController {
    @Resource
    private ICustomerService customerService;

    @RequestMapping("/save")
    public QDResult save(Customer customer){
        return customerService.save(customer);
    }

    @RequestMapping("/edit")
    public QDResult edit(Customer customer){
        return customerService.edit(customer);
    }

    @RequestMapping("/delete")
    public QDResult delete(Customer customer){
        return customerService.delete(customer);
    }

    @RequestMapping("/get")
    public QDResult<Customer> get(Long id){
        return customerService.get(id);
    }

    @RequestMapping("/query")
    public LayuiTableDTO<Customer> query(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10")int limit, Customer customer){
        return customerService.query(page, limit, customer);
    }
    @RequestMapping("/reg")
    public QDResult reg(Customer customer){
        return customerService.reg(customer);
    };

    @RequestMapping("/login")
    public QDResult login(String loginName,String password){
        return customerService.login(loginName,password);
    }
}